<?php
	$lang = isset($_GET['lang']) ? $_GET['lang'] : 'it';
	
	define(HTML_PATH, './pages/html/');
	define(STORE_PATH, './store/');
	define(ROOT_PATH,'./');	
	
	require_once ('./language/'.$lang.'/calendarLanguage.php');
	require_once ('class.layout.php');
	require_once ('class.referee.php');
	require_once ('class.pageContent.php');
	require_once ('class.pfTranslator.php');
	require_once ('pages/class.simpleTable.php');
	require_once ('pages/class.pfMainPage.php');
	require_once ('pages/class.pfCalendar.php');
	require_once ('class.uploadManager.php');
	
	$callName = null;
	if (isset($_GET['calName']))
		$callName = $_GET['calName'];
		
	switch ($_GET['page']){
		case 'calendar': $pfPage = new pfCalendar(); break;
		default: $pfPage = new pfMainPage(); break;
	}
		
	$referee = new referee();
	$referee->setLanguage($lang);
	$referee->setPageManager($pfPage);
	
	$referee->makeAction();
	echo $referee->makeVisible();
	
	/*
	echo '<pre>';
	print_r ($_POST);
	echo '</pre>';
	
	$pfCalendar = new pfCalendar();
	
	if (isset($_POST['action'])) {
		if (empty($_POST["weekDays"]) || empty($_POST["yearMonths"]) || empty($_POST['calendarName'])){
			$pfCalendar->setError('manca roba');				
		}
		$pfCalendar->setData($_POST);
		$finalCalendar = $pfCalendar->buildCalendar();
		
		$now = date ("Ymd");
		$cName = $now.$_POST['calendarName'];
		$totalCode = $printCode = "";
		foreach ($finalCalendar as $index=>$month){
			$totalCode .= '<div style="position:relative;width:100%;float:left;">'.$month.'</div>';
			$fName = $cName.'_'.($index+1).'.html';
			file_put_contents('./calendars/'.$cName.'_'.($index+1).'.html', $month);
			$printCode .= '<div style="width:100%;float:left;"><a href="./calendars/'.$fName.'"/>'.$month.'</a></div><br />';
		}
				
		file_put_contents('./calendars/'.$cName.'_totale.xls', $totalCode);
		echo '<a href="./calendars/'.$cName.'_totale.xls">SCARICA INTERO CALENDARIO</a>';
		echo '<br /><br />';
		echo $printCode;
		//echo $totalCode;
	}
	else {
		echo $pfCalendar->buildSheet();
	}
	*/
	
?>